local que_xueshi = fk.CreateSkill {
    name = "que_xueshi",
    anim_type = "control",
    tags = { Skill.Compulsory }
}
Fk:loadTranslationTable {
    ["que_xueshi"] = "血噬",
    [":que_xueshi"] = "锁定技，当你受到非转化非虚拟牌造成的伤害后，你记录此牌的牌名；当一张牌名被首次记录时，你摸一张牌，" ..
        "第二次被记录时，你使用此牌名的牌时摸一张牌，第三次被记录时，你摸等量张牌，然后移去记录中的所有此牌名；若此牌对你造成的伤害值大于1，则改为记录伤害值等量的牌名。",

    ["@$que_xueshi"] = "血噬",
}
que_xueshi:addEffect(fk.Damaged, {
    can_trigger = function(self, event, target, player, data)
        return target == player and
            player:hasSkill(que_xueshi.name) and data.card and not data.card:isVirtual() and data.damage > 0
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local mark = player:getTableMark("@$que_xueshi")
        for i = 1, data.damage, 1 do
            room:addTableMark(player, "@$que_xueshi", data.card.trueName)
            mark = player:getTableMark("@$que_xueshi")
            local n = 0
            for _, id in ipairs(mark) do
                local card = Fk:cloneCard(id)
                if card.trueName == data.card.trueName then
                    n = n + 1
                end
            end
            if n == 1 then
                player:drawCards(1, que_xueshi.name)
            end
            if n == 3 then
                for x = 1, n, 1 do
                    room:removeTableMark(player, "@$que_xueshi", data.card.trueName)
                end
                player:drawCards(n, que_xueshi.name)
            end
        end
    end,
})
que_xueshi:addEffect(fk.CardUsing, {
    can_trigger = function(self, event, target, player, data)
        local mark = player:getTableMark("@$que_xueshi")
        local n = 0
        for _, id in ipairs(mark) do
            local card = Fk:cloneCard(id)
            if card.trueName == data.card.trueName then
                n = n + 1
            end
        end
        return target == player and player:hasSkill(que_xueshi.name) and table.contains(mark, data.card.trueName) and
            n == 2
    end,
    on_use = function(self, event, target, player, data)
        player:drawCards(1, que_xueshi.name)
    end,
})
return que_xueshi
